CC=g++
#GTESTPATH=/opt/usr
#GMOCKPATH=/opt/usr
#GTESTPATH=/home/xiamc/tools/gmock-1.6.0/gtest
#GMOCKPATH=/home/xiamc/tools/gmock-1.6.0
#PROJ_HOME=/home/xiamc/svn/itrans/pub/MulLangPreProcess
#INCLUDES=-I./ -I$(GTEST_HOME)/include 

TYPE=debug
GTEST_HOME=/opt/usr

INCLUDES=-I./ -I$(GTEST_HOME)/include
CFLAGS=-g
LDFLAGS=-lgcov -lgtest -lgtest_main -lpthread -lutil
LIBS=-L$(GTEST_HOME)/lib -L/user/lib -L./

ifeq ($(TYPE), debug)
CFLAGS += -g3 
else
ifeq ($(TYPE), release)
CFLAGS += -O3 
else
CFLAGS += -g -O
endif
endif


all:libutil.a client server test
server : server.o libutil.a
	$(CC) -o $@ $^ $(LDFLAGS) $(LIBS)
server.o : server.cpp
	$(CC) $(CFLAGS) -c $< $(INCLUDES)
client : client.o libutil.a
	$(CC) -o $@ $^ $(LDFLAGS) $(LIBS)
client.o : client.cpp  
	$(CC) $(CFLAGS) -c $< $(INCLUDES)
test : test.o libutil.a
	$(CC) -o $@ $^ $(LDFLAGS) $(LIBS)
test.o : test.cpp  
	$(CC) $(CFLAGS) -c $< $(INCLUDES)
libutil.a : util.o
	ar crv libutil.a util.o
util.o : util.cpp
	$(CC) $(CFLAGS) -c $< $(INCLUDES)
.phony:clean
clean:
	/bin/rm -f test.o test client.o client server.o server libutil.a *.gcda *.gcno util.o
